package scau.jump.securitytrace;

import java.util.Observable;

import org.apache.log4j.Logger;

import scau.jump.rfid.driver.Reader;
import scau.jump.rfid.driver.console.ConsoleDriver;

public class RFIDMonitor extends Observable implements Runnable{

	private static Logger logger = Logger.getLogger(RFIDMonitor.class);
	
	private boolean isRunning = true;
	
	ConsoleDriver driver = new ConsoleDriver();
	
	@Override
	public void run() {
		while(isRunning){
			logger.debug("正在监听......");
			
			Reader reader = driver.getReader();
			
			if(true){//判断是否读到RFID
				setChanged();
				notifyObservers(reader);
			}
		
			try {
				Thread.sleep(3000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

	public void stop(){
		isRunning = false;
	}
	
	public void runing(){
		isRunning = true;
	}
}
